﻿using System;
using System.Diagnostics;

namespace ThePresenter.Net.NetCom
{
	/// <summary>
	/// Class used to output debug messages
	/// </summary>
	public class DebugClass
	{
		#region Fields

		private const string DebugConst = "DEBUG";

		public static Guid LocalhostDebugGuid;

		private String _Category;

		public static Boolean Enabled = true;

		#endregion

		#region Constructors

		/// <summary>
		/// Initializes a new instance of the <see cref="DebugClass"/> class.
		/// </summary>
		/// <param name="Category">The category.</param>
		public DebugClass(String Category)
		{
			this._Category = Category;
		}

		#endregion

		#region Methods

		[Conditional(DebugConst)]
		public void Write(String Message, params object[] args)
		{
			if (DebugClass.Enabled)
				Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.FFFF") + " " + String.Format(Message, args), this._Category);
		}

		[Conditional(DebugConst)]
		public static void DebugWrite(String Category, String Message, params object[] args)
		{
			if (DebugClass.Enabled)
				Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.FFFF") + " " + String.Format(Message, args), Category);
		}

		[Conditional(DebugConst)]
		public static void ShowMessage(string p, params object[] args)
		{
			System.Windows.MessageBox.Show(String.Format(p, args));
		}

		#endregion
	}
}
